package com.raisecom.socket;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;


public class MyServerSocket {
	
	
	public static void main(String[] args) {
		try {
			ServerSocket serverSocket = new ServerSocket(5555);
			
			while (true) {
				Socket accept = serverSocket.accept();
				InputStream inputStream = accept.getInputStream();
				OutputStream outputStream = accept.getOutputStream();
				
				BufferedReader bufr = new BufferedReader(new InputStreamReader(inputStream));
				BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(outputStream));
				
				String line = null;
				
				line = bufr.readLine();
				System.out.println(line);
				
				bufw.write(line.toUpperCase());
				bufw.newLine();
				
				bufw.close();
				
				accept.close();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
